package com.codemonkey.lq.test.sampledata.deprecated;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.collection.CollectionUtil;

/**
 * @author LQ
 * @deprecated 之后的项目不要再使用本类了
 */
@Deprecated
public class PersonDeprecated implements Serializable {
	private String lastName = "default lastname";
	private String firstName = "default firstname";
	private String name = "default full name";
	private int age;
	private String gender;
	private String nullField;
	
	// 主要是为了测试Spring的SpEL
	private PersonDeprecated child; // 参见SpEl_Tests.java 中的 call_SpEL_IN_java 方法
	// 主要为了测试 反射性的方法,例如org.apache.commons.lang3.reflect.FieldUtils.writeField等
	private final String finalName = "FINAL_NAME";

	@Deprecated
	private final String reflectField = "本字段用于测试org.apache.commons.lang3.reflect.FieldUtils类";

	public static List<PersonDeprecated> getPersonGroup() {
		ArrayList<PersonDeprecated> persons = CollectionUtil.newArrayList();
		persons.add(new PersonDeprecated() {
			{
				this.setFirstName("One");
				this.setLastName("OneEnd");
			}
		});
		persons.add(new PersonDeprecated() {
			{
				this.setFirstName("Two");
				this.setLastName("TwoEnd");
			}
		});
		persons.add(new PersonDeprecated() {
			{
				this.setFirstName("Three");
				this.setLastName("ThreeEnd");
			}
		});
		persons.add(new PersonDeprecated() {
			{
				this.setFirstName("Four");
				this.setLastName("FourEnd");
			}
		});
		persons.add(new PersonDeprecated() {
			{
				this.setFirstName("Five");
				this.setLastName("FiveEnd");
			}
		});

		return persons;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}
	
	

	public String getNullField() {
		return nullField;
	}

	public void setNullField(String nullField) {
		this.nullField = nullField;
	}

	public static PersonDeprecated getSinglePerson() {
		PersonDeprecated person = new PersonDeprecated();
		person.setFirstName("One");
		person.setLastName("OneEnd");
		person.setAge(18);
		person.setGender("Female");
		person.setName("Lili");
		return person;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public PersonDeprecated getChild() {
		return child;
	}

	public void setChild(PersonDeprecated child) {
		this.child = child;
	}

	protected void say() {
		System.out.println("i am [ person ]");
	}
	
	@Override
	public boolean equals(Object other) {		
		if (this == other) {
			return true;
		}

		if (other == null || other.getClass() != this.getClass()) {
			return false;
		}

		PersonDeprecated that = (PersonDeprecated) other;

		if (this.age == that.age && this.name.equalsIgnoreCase(that.name)) {
			return true;
		}

		//其它的比较交给父类
		return super.equals(other);
	}

	@Override
	public String toString() {
		return String.format("%s + %s", getFirstName(), getLastName());
	}

}
